package com.kancy.demo.streamplus.controller;

import com.kancy.demo.streamplus.channel.message.TextMessage;
import com.kancy.streamplus.service.PollingMessageService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.time.Duration;

/**
 * TestController
 *
 * @author kancy
 * @date 2020/3/22 20:37
 */
@RequiredArgsConstructor
@RestController
public class TestController {

    private final PollingMessageService pollingMessageService;

    @GetMapping("/test/send")
    public String sendMessage(long delay){
        TextMessage message = new TextMessage("你好");
        message.setDelay(Duration.ofMillis(delay));
        pollingMessageService.sendMessage(message);
        return "ok";
    }

}
